package com.cyandpos.pad.pay.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;


import com.cyandpos.pad.R;
import com.cyandpos.pad.posdata.O2OPayDetail;
import com.cyandpos.pad.utils.MoneyUtils;

import java.util.List;

public class O2oItemsAdapter extends BaseAdapter {
    private List<O2OPayDetail> mList;
    private Context mContext;

    public O2oItemsAdapter(List<O2OPayDetail> list, Context context) {
        this.mList = list;
        this.mContext = context;
    }

    @Override
    public int getCount() {
        return mList.size();
    }

    @Override
    public Object getItem(int position) {
        return mList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(R.layout.pay_o2o_item, null);
            holder.itemNo = (TextView)convertView.findViewById(R.id.pay_orderNo);
            holder.itemSum = (TextView)convertView.findViewById(R.id.pay_orderSum);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        O2OPayDetail item = mList.get(position);
        holder.itemNo.setText("单号["+item.getOutTradeNo()+"]");
        holder.itemSum.setText("金额["+ MoneyUtils.getMoneyStr(item.getTotalFee()+
        		item.getCouponFee() + item.getCouponFeeShop())+"]") ;
        return convertView;
    }
    class ViewHolder{
        LinearLayout ll;
        TextView itemNo,itemSum;
    }
}
